<extend name="layout/main" />

<block name="HEADER">
	<style type="text/css">
		.layui-layer-page .layui-layer-content{
			overflow: initial;
		}
		#grid .layui-table-view .layui-table td .layui-table-cell{
			height: 36px;
		    line-height: 36px;
		}
		#grid .layui-btn+.layui-btn {
		    margin-left: 0;
		}
		.xw-layui-layer .layui-layer-content{
			padding: 0;
		}
		.xw-form .xw-form-formType-div{
			height: 100%;
		}
	</style>
</block>

<block name="CONTENT">
	<div class="wrapper">
		<div class="panel-heading">
			<control:search id="searchs" />
		</div>
		<div class="content">
			<control:grid id="grid" padding="0" height="100%" />
		</div>
	</div>

	<script id="tplExcelImport" type="text/html">
		<div id='excelImportFrom'></div>
	</script>
</block>

<block name="FOOTER">
	<script type="text/javascript">
		var page = (function(ns){

		    //页面初始化
		    ns.init=function(){
                //页面传值，选择了，就不显示。
                ns.query();
		    }


            //搜索事件
            ns.query=function(){
                var filter = searchs.getData();
                grid.load(filter);
            }

            //编辑显示
			ns.edit = function(){
                var selectedRow = grid.getSelectedRows()[0];
                var filter = searchs.getData();
				var shop_id='';
                var months='';

                filter.forEach(function(e) {
                    if(e.field=="shop_id"){
                        shop_id=e.value;
                    }
                    if(e.field=="months"){
                        months=e.value;
                    }
                });

                //先异步查出，是否存在了
                $.ajaxs('/admin/v1/shop_staff/getown',{
                    staff_id:selectedRow.id,
                    months:months
                }).then(function(res){
                	var filter = {
                        url: "/modules/finance/wages/edit",
                        oid: res.data ? res.data.id : selectedRow.id ,
                        shop_id: shop_id ,
                        months: months,
                        mode: res.data ? 2 : 1 ,
                   	}
					window.staffInfo=selectedRow;
                    $.openIframe(filter, "编辑",['650px', '550px']);
                });

			}


		    return ns;
		}({}));


		$(function(){ page.init();  });

	</script>
</block>